package com.lj.demo.statisticsService.controller;


import com.lj.demo.commonutils.R;
import com.lj.demo.statisticsService.entity.StatisticsDaily;
import com.lj.demo.statisticsService.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.ehcache.core.spi.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author liujiang
 * @since 2021-01-17
 */
@RestController
@RequestMapping("/statisticsService/statisticsDaily")
@CrossOrigin
public class StatisticsDailyController {


    @Autowired
    private StatisticsDailyService dailyService;

    @ApiOperation("统计传入日期的注册人数加入数据库")
    @PostMapping("createStatisticByDate/{day}")
    public R createStatisticByDate(@PathVariable String day){
        dailyService.createStatisticByDate(day);
        return R.ok();
    }

    @ApiOperation("获取区间统计的信息")
    @GetMapping("showChart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,
                       @PathVariable String end,
                       @PathVariable String type){
        Map<String,Object> map =dailyService.getChartData(begin,end,type);
        return R.ok().data(map);
    }

}

